package com.agileboot.domain.system.dict.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author valarchie
 * @since 2024-10-12
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictTypeEntity> implements SysDictTypeService {
    @Override
    public boolean isParameterDuplicated(String parameter, String sqlParameterName, Long id,String sqlIdName) {
        QueryWrapper<SysDictTypeEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne(id != null, sqlIdName, id)
                .eq(sqlParameterName, parameter);
        return baseMapper.exists(queryWrapper);
    }


    /**
     * 检查字典类型是否存在数据
     * @param dictType 字典类型
     * @return 数据量
     */
    @Override
    public int checkDictDataExists(String dictType) {
        return baseMapper.countDictDataByType(dictType);
    }
}
